const wxTemplateMessageApi = require('../weixin/templatemessage');
const { timestampConvert } = require('../../module/tool/time');

const templateIds = {
    dormitoryOrderPlaceMessage: '{订阅消息id}'
};

async function dormitoryOrderPlaceMessage (business, openid, productName, price, createNickname, time, orderId, schoolId, page) {
    const templateId = templateIds.dormitoryOrderPlaceMessage;
    const data = {
        first: {
            value: `有新的${business}订单`
        },
        keyword1: {
            value: productName
        },
        keyword2: {
            value: '佣金:' + (price / 100).toFixed(2) + '元',
            color: '#ff0000'
        },
        keyword3: {
            value: createNickname
        },
        keyword4: {
            value: timestampConvert('yyyy年M月d日 hh:mm', time)
        },
        keyword5: {
            value: orderId
        },
        remark: {
            value: '点击消息立即接单',
            color: '#ff0000'
        }
    };
    return wxTemplateMessageApi.sendTemplateMessage(openid, templateId, page, data);
}

module.exports = {
    dormitoryOrderPlaceMessage
};
